﻿namespace TrafficWebApi.Models.Response
{
    public class ResultJson
    {
        #region Model
        /// <summary>
        /// 结果码
        /// </summary>
        public int resultCode { get; set; } = 999;
        /// <summary>
        /// 返回数据
        /// </summary>
        public object? data { get; set; } = new object();
        /// <summary>
        /// 返回信息
        /// </summary>
        public string errMsg { get; set; } = string.Empty;
        /// <summary>
        /// 总记录数
        /// </summary>
        public int totalCount { get; set; } = 0;
        #endregion

        #region 构造函数
        public ResultJson SetResultMsg(int code, string errmsg, object? dataObj)
        {
            this.resultCode = code;
            this.errMsg = errmsg;
            this.data = dataObj;
            return this;
        }

        public ResultJson SetResultMsg(int code, string errmsg, int totalCount, object? dataObj)
        {
            this.resultCode = code;
            this.errMsg = errmsg;
            this.data = dataObj;
            this.totalCount = totalCount;
            return this;
        }
        #endregion
    }
}